package de.iritgo.skillfull.director.attacktype;

import de.iritgo.skillfull.director.AttackStrategy;
import de.iritgo.skillfull.director.AttackType;
import de.iritgo.skillfull.entity.Entity;

public class EndgameAttackWithSpeeder extends AbstractAttack implements AttackType 
{
	public EndgameAttackWithSpeeder(AttackStrategy attackStrategy) 
	{
		super (attackStrategy);
	}

	public int attackBottom (int heroHealth, int enemies, int timeLeft) 
	{
		attackAll (heroHealth, enemies, timeLeft);
		return 1;
	}

	public int attackLeft (int heroHealth, int enemies, int timeLeft) 
	{
		attackAll (heroHealth, enemies, timeLeft);
		return 1;
	}

	public int attackRight (int heroHealth, int enemies, int timeLeft) 
	{
		attackAll (heroHealth, enemies, timeLeft);
		return 1;
	}

	public int attackTop (int heroHealth, int enemies, int timeLeft) 
	{
		attackAll (heroHealth, enemies, timeLeft);
		return 1;
	}

	public void attackAll (int heroHealth, int enemies, int timeLeft)
	{
		int y = 1024 + 32, moves = 5;
		
		for (int x = 0; x < 17 ; ++x)
		{
			int start = generator.nextInt (40);
			if (generator.nextBoolean ())
			{
				createEnemy ("alien1", x * (32 + start), y, moves, Entity.DST_FIELD.NORTH);
			}
			else
			{
				createEnemy ("alien2", x * (32 + start), y, moves, Entity.DST_FIELD.NORTH);
			}
		}

		int x = -32;
		
		for (y = 0; y < 17 ; ++y)
		{
			int start = generator.nextInt (50);
			if (generator.nextBoolean ())
			{
				createEnemy ("alien1", x, y * (32 + start), moves, Entity.DST_FIELD.EAST);
			}
			else
			{
				createEnemy ("alien2", x, y * (32 + start), moves, Entity.DST_FIELD.EAST);
			}
		}

		x = 1280 + 32;
		
		for (y = 0; y < 17 ; ++y)
		{
			int start = generator.nextInt (50);
			if (generator.nextBoolean ())
			{
				createEnemy ("alien1", x, y * (32 + start), moves, Entity.DST_FIELD.WEST);
			}
			else
			{
				createEnemy ("alien2", x, y * (32 + start), moves, Entity.DST_FIELD.WEST);
			}
		}

		y = 0 - 32;
		
		for (x = 0; x < 17 ; ++x)
		{
			int start = generator.nextInt (50);
			if (generator.nextBoolean ())
			{
				createEnemy ("alien1", x * (32 + start), y, moves, Entity.DST_FIELD.SOUTH);
			}
			else
			{
				createEnemy ("alien2", x * (32 + start), y, moves, Entity.DST_FIELD.SOUTH);
			}
				
		}
	}
	
}
